Currently, computer technologies are developing increasingly. The transmission rate and bandwidth are increasing with the progress of technologies. Accordingly, the transmitted data flow increases as well. In the transmitted data, computer viruses or advertisement web pages can be included, delaying the system processing speed or even poisoning the system and thus making the system abnormal. Thereby, in many applications of modern systems, for example, web switches, load balancers, and virus protection, the data content will be examined one by one for preventing the problems described above. This is so-called content scanning.
FIG. 1 shows a scanning circuit for data content according to the prior art. As shown in the figure, a scanning circuit 10′ comprises a plurality of comparators 20′. Since the location of the content in the packet data to be searched is uncertain, the plurality of comparators 20′ has to scan all content of said packet data one by one for ensuring that no scanning loss occurs. As shown in FIG. 1, after comparing the first to the fifth bytes of the packet data, the second to the sixth bytes are compared subsequently. Thereby, the second to the fifth bytes are usually cached for next comparison. In addition, since the scanning circuit is applied extensively and the guidelines of categorization for various applications differ, the length of each rule varies accordingly. For example, when the number of rules to be scanned is 10, the shortest length thereof might be two to three bytes only, while the longest might be tens of byte. In order to solve the problem of rules with different lengths, the size of rules is set fixed. If a shorter rule is to be set, a mask 22′ is adopted, and the comparator 20′ is used for deciding whether the data to be scanned is satisfied. Hence, extra cache space is wasted for comparison, and the implementation circuits are relatively complicated. Besides, for longer rules, a larger cache space is needed.
Accordingly, the present invention provides a scanning circuit and method for data content, which can save circuit area and dynamically configure the length of scanning rules. Thereby, scanning flexibility is enhanced and scanning time is shortened.